Skip to content

fix: context condensing prompt not saving properly#5634

Merged
kevinvandijk merged 4 commits intoKilo-Org:mainfrom
Patel230:fix-5629-condensing-prompt
Feb 21, 2026
Merged

fix: context condensing prompt not saving properly#5634
kevinvandijk merged 4 commits intoKilo-Org:mainfrom
Patel230:fix-5629-condensing-prompt

Conversation

@Patel230
Copy link
Copy Markdown

@Patel230 Patel230 commented Feb 3, 2026

Fixes #5629

Problem

Context condensing prompt was clearing out and not saving properly when typing.

Root Cause

The VSCodeTextArea was directly controlled by extension state. Every keystroke triggered a save to extension state → webview re-render → race condition caused text to clear.

Solution

  • Added local React state buffer (localCondensingPrompt)
  • Update local state on input (smooth typing, no flicker)
  • Sync with extension state on blur (save when done typing)
  • Initialize local state when switching to CONDENSE tab

Changes

  • Modified: webview-ui/src/components/settings/PromptsSettings.tsx

Testing

  • Type in CONDENSE textarea - no longer clears while typing
  • Click outside (blur) - saves properly to extension state
  • Switch tabs and back - value persists correctly
  • Reset button works correctly

Fixes Kilo-Org#5629

- Add local state for condensing prompt to prevent flickering during typing
- Initialize local state when switching to CONDENSE tab
- Sync with extension state on blur to ensure persistence
- Prevent race condition between user input and extension state updates
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Feb 3, 2026

🦋 Changeset detected

Latest commit: caef0f0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
kilo-code Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

if (activeSupportOption === "CONDENSE") {
setLocalCondensingPrompt(customCondensingPrompt)
}
}, [activeSupportOption, customCondensingPrompt])
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[WARNING]: Including customCondensingPrompt in this dependency array may undermine the anti-flickering protection.

When the user is actively typing, the flow is:

  1. onInputsetLocalCondensingPrompt(value) + updateSupportPrompt(...)setCustomCondensingPrompt(value) + vscode.postMessage(...)
  2. If the extension processes the message and sends back a different/normalized value (e.g., via ExtensionStateContext), customCondensingPrompt changes
  3. This useEffect fires and overwrites localCondensingPrompt with the extension's value — exactly the flickering scenario this PR aims to prevent

Consider depending only on activeSupportOption so the local state is initialized only when switching tabs, not overwritten during active editing:

Suggested change
}, [activeSupportOption, customCondensingPrompt])
}, [activeSupportOption]) // eslint-disable-line react-hooks/exhaustive-deps

Alternatively, you could use a ref to track whether the user is actively editing and skip the sync in that case.

@kilo-code-bot
Copy link
Copy Markdown
Contributor

kilo-code-bot Bot commented Feb 21, 2026

Code Review Summary

Status: 1 Issue Found | Recommendation: Address before merge

Fix these issues in Kilo Cloud

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
webview-ui/src/components/settings/PromptsSettings.tsx 83 Including customCondensingPrompt in the useEffect dependency array may cause the local state to be overwritten during active editing, undermining the anti-flickering fix
Other Observations (not in diff)

Issues found in unchanged code or cross-cutting concerns that cannot receive inline comments:

File Line Issue
webview-ui/src/components/settings/PromptsSettings.tsx 116-126 Reset interaction: handleSupportReset("CONDENSE") does not clear localCondensingPrompt. If the dependency array fix from the WARNING above is applied (removing customCondensingPrompt), clicking reset while the CONDENSE tab is active would show stale local state in the textarea. Consider adding setLocalCondensingPrompt(undefined) inside handleSupportReset when type === "CONDENSE".
webview-ui/src/components/settings/PromptsSettings.tsx 214-223 Redundant update on blur: The onBlur handler calls updateSupportPrompt again even though onInput already sent the value on every keystroke. Since updateSupportPrompt posts a message to the extension, this results in a duplicate message. Consider only resetting local state (setLocalCondensingPrompt(undefined)) in onBlur without re-calling updateSupportPrompt.
webview-ui/src/components/settings/PromptsSettings.tsx N/A Missing test coverage: No test file exists for PromptsSettings. The new local state buffering logic (especially the interaction between localCondensingPrompt, the useEffect sync, and onBlur reset) would benefit from unit tests to verify the anti-flickering behavior works correctly.
Files Reviewed (2 files)
  • .changeset/fix-condensing-prompt.md - 0 issues
  • webview-ui/src/components/settings/PromptsSettings.tsx - 1 issue (inline) + 3 observations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Context Condensing is not saving

2 participants